package com.htgd.gardenexpo;

//import cn.xuyanwu.spring.file.storage.EnableFileStorage;
import cn.xuyanwu.spring.file.storage.EnableFileStorage;
import com.alibaba.fastjson.parser.ParserConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.PostConstruct;
import java.util.TimeZone;

/**
 * @author 何京
 */
@EnableScheduling
@SpringBootApplication
@EnableFileStorage
@ServletComponentScan
@SpringBootConfiguration
@MapperScan("com.htgd.gardenexpo.dao")
@EnableTransactionManagement
public class GardenexpoApplication {

    public static void main(String[] args) {
        ParserConfig.getGlobalInstance().setSafeMode(true);
        SpringApplication.run(GardenexpoApplication.class, args);
    }


    //允许http请求含有字符[]{}
    @Bean
    public TomcatServletWebServerFactory tomcatServletWebServerFactory (){

        // 修改内置的 tomcat 容器配置
        TomcatServletWebServerFactory tomcatServlet = new TomcatServletWebServerFactory();
        tomcatServlet.addConnectorCustomizers(
                (TomcatConnectorCustomizer) connector -> connector.setProperty("relaxedQueryChars", "[]")
        );

        return tomcatServlet ;
    }

    @PostConstruct
    void started() {
        TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
    }
}
